package interview;
//面试题 02.02. 返回倒数第 k 个节点
public class Num02_02_kthToLast {
    public int kthToLast(ListNode head, int k) {
        ListNode prev = head;
        ListNode cur = head;
        for (int i = 0; i < k; i++) {
            cur=cur.next;
        }
        while (cur!=null){
            prev=prev.next;
            cur=cur.next;
        }
        return prev.val;
    }
}
